import React, { Component } from 'react';
import {
  Table,
} from 'antd';

interface TotalIncomeProps {
  detailList: any;
}

class TotalIncome extends Component<TotalIncomeProps> {
  columns: any = [
    {
      title: '总收入',
      dataIndex: 'total_income',
      align: 'center',
      render: (text: any, row: any, index: any) => {
        const { detailList } = this.props;
        const values = index === 0
          ? { children: text, props: { rowSpan: detailList.length } }
          : { props: { colSpan: 0 } };
        return values;
      },
    },
    {
      title: '地区总收入',
      dataIndex: 'garden_total_income',
      align: 'center',
    },
    {
      title: '寄件',
      dataIndex: 'garden_cab_sending_income',
      align: 'center',
    },
    {
      title: '柜体寄存',
      dataIndex: 'deposit_income',
      align: 'center',
    },
    {
      title: '取件账户',
      dataIndex: 'pickup_income',
      align: 'center',
    },
    {
      title: '投递账户',
      dataIndex: 'delivery_income',
      align: 'center',
    },
    {
      title: '业务',
      dataIndex: 'biz_type_desc',
      align: 'center',
    },
    {
      title: '地区',
      dataIndex: 'darea_code_name',
      align: 'center',
    },
  ]

  render() {
    const { detailList } = this.props;
    const data = detailList.map((item: any, index: number) => {
      item.id = index;
      return item;
    });
    return (
      <Table
        rowKey="id"
        bordered
        className="statementTable tableList"
        columns={this.columns}
        dataSource={data}
        pagination={false}
      />
    );
  }
}

export default TotalIncome;
